package com.javaclimb.music.controller;

import com.alibaba.fastjson.JSONObject;
import com.javaclimb.music.domain.Admin;
import com.javaclimb.music.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import static com.javaclimb.music.enums.ResponseEnum.SUCCESS_LOGIN;


/**
 * @author 最酷的桃儿wjc
 * * @date 2022/5/10
 */
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping(value = "/login/status",method = RequestMethod.POST)
    public Object loginStatus(Admin admin){
        JSONObject jsonObject = new JSONObject();

        boolean lgoinFlag = adminService.verifyPassword(admin.getName(), admin.getPassword());

        if (lgoinFlag){
            jsonObject.put("code",SUCCESS_LOGIN.getCode());
            jsonObject.put("msg",SUCCESS_LOGIN.getMsg());
        }

        return jsonObject;
    }
}
